package com.nondo.rdp.core.model;

import java.util.ArrayList;
import java.util.List;

import com.nondo.rdp.core.common.BeanUtils;
import com.nondo.rdp.core.common.CommUtil;
import com.nondo.rdp.core.domain.attach.Attach;
import com.nondo.rdp.core.domain.attach.AttachConfig;

/**
 * 文件
 */

public class AttachBean {
    private Long id;        //自增ID
    private String path;    // 文件路径地址
    private int type;   // 文件类型
    private String remark;  // 备注
    private String videoId; //阿里云视频ID
    private List<AttachConfig> attachConfigs; //图片配置

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPath() {
		if (type == 0) {
			return CommUtil.getFileUrl(path);
		}
		return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }
    
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
    
    public String getVideoId() {
		return videoId;
	}

	public void setVideoId(String videoId) {
		this.videoId = videoId;
	}

	public List<AttachConfig> getAttachConfigs() {
		return attachConfigs;
	}

	public void setAttachConfigs(List<AttachConfig> attachConfigs) {
		this.attachConfigs = attachConfigs;
	}

	public static List<AttachBean> covert2BeanList(List<Attach> attachList) {
		List<AttachBean> attachBeans = new ArrayList<AttachBean>();
		for(Attach attach : attachList) {
			AttachBean attachBean = AttachBean.covert2Bean(attach);
			attachBeans.add(attachBean);
		}
		return attachBeans;
	}

	public static AttachBean covert2Bean(Attach attach) {
		AttachBean attachBean = new AttachBean();
		BeanUtils.copy(attach, attachBean);
		return attachBean;
	}
}